//
//  BPRequestProtocol.h
//  BPRequestTool_Example
//
//  Created by SiYugui on 2020/4/29.
//  Copyright © 2020年 xuhongji. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "AFHTTPSessionManager+Share.h"

#define BPRequestTimeoutInterval 30

typedef NS_ENUM(NSUInteger, BPResponseSerializerType) {
    
    BPResponseSerializerTypeDefault = 0, //默认类型 默认类型 Data  如果使用这个响应解析器类型,那么请求返回的数据将会是二进制格式
    BPResponseSerializerTypeJson, //JSON类型 如果使用这个响应解析器类型,那么请求返回的数据将会是JSON格式
    BPResponseSerializerTypeImage, //Image类型 如果使用这个响应解析器类型,那么请求返回的数据将会是Image格式
    BPResponseSerializerTypeData //Data类型 如果使用这个响应解析器类型,那么请求返回的数据将会是二进制格式
};

typedef NS_ENUM(NSUInteger, BPRequestSerializerType) {
    BPRequestSerializerDefault = 0,
    BPRequestSerializerJson
};


@protocol BPRequestProtocol <NSObject>

/**
 GET请求 By NSURLSession
 
 @param URLString URL
 @param parameters 参数
 @param headers 请求头
 @param requestSerializer 请求数据类型
 @param responseSerializer 数据解析器类型
 @param success 请求成功的回掉
 @param failure 请求失败的回掉
 */
+ (NSURLSessionDataTask *_Nonnull)GET:(NSString *_Nonnull)URLString
                           parameters:(id _Nullable)parameters
                              headers:(nullable NSDictionary <NSString *, NSString *> *)headers
                    requestSerializer:(BPRequestSerializerType)requestSerializer
                   responseSerializer:(BPResponseSerializerType)responseSerializer
                              success:(nullable void(^)(id _Nullable responseObject))success
                              failure:(nullable void(^)(NSError *_Nullable error))failure;

/**
 POST请求 By NSURLSession
 
 @param URLString URL
 @param parameters 参数
 @param headers 请求头
 @param requestSerializer 请求数据类型
 @param responseSerializer 数据解析器类型
 @param success 请求成功的回掉
 @param failure 请求失败的回掉
 */
+ (NSURLSessionDataTask *_Nonnull)POST:(NSString *_Nonnull)URLString
                            parameters:(id _Nullable)parameters
                               headers:(nullable NSDictionary <NSString *, NSString *> *)headers
                     requestSerializer:(BPRequestSerializerType)requestSerializer
                    responseSerializer:(BPResponseSerializerType)responseSerializer
                               success:(nullable void(^)(id _Nullable responseObject))success
                               failure:(nullable void(^)(NSError *_Nullable error))failure;

/**
 PUT请求 By NSURLSession
 
 @param URLString URL
 @param parameters 参数
 @param headers 请求头
 @param requestSerializer 请求数据类型
 @param responseSerializer 数据解析器类型
 @param success 请求成功的回掉
 @param failure 请求失败的回掉
 */
+ (NSURLSessionDataTask *_Nonnull)PUT:(NSString *_Nonnull)URLString
                           parameters:(id _Nullable)parameters
                              headers:(nullable NSDictionary <NSString *, NSString *> *)headers
                    requestSerializer:(BPRequestSerializerType)requestSerializer
                   responseSerializer:(BPResponseSerializerType)responseSerializer
                              success:(nullable void(^)(id _Nullable responseObject))success
                              failure:(nullable void(^)(NSError * _Nullable error))failure;

/**
 DELETE请求 By NSURLSession
 
 @param URLString URL
 @param parameters 参数
 @param headers 请求头
 @param requestSerializer 请求数据类型
 @param responseSerializer 数据解析器类型
 @param success 请求成功的回掉
 @param failure 请求失败的回掉
 */
+ (NSURLSessionDataTask *_Nonnull)DELETE:(NSString *_Nonnull)URLString
                              parameters:(id _Nullable)parameters
                                 headers:(nullable NSDictionary <NSString *, NSString *> *)headers
                       requestSerializer:(BPRequestSerializerType)requestSerializer
                      responseSerializer:(BPResponseSerializerType)responseSerializer
                                 success:(nullable void(^)(id _Nullable responseObject))success
                                 failure:(nullable void(^)(NSError *_Nullable error))failure;


/**
 POST上传数据
 
 @param URLString URL
 @param parameters 参数
 @param headers 请求头
 @param requestSerializer 请求数据类型
 @param responseSerializer 数据解析类型
 @param block formData
 @param progress 上传进度
 @param success 请求成功回掉
 @param failure 请求失败回掉
 */
+ (NSURLSessionDataTask *_Nonnull)POST:(NSString *_Nonnull)URLString
                            parameters:(id _Nullable)parameters
                     requestSerializer:(BPRequestSerializerType)requestSerializer
                               headers:(nullable NSDictionary <NSString *, NSString *> *)headers
                    responseSerializer:(BPResponseSerializerType)responseSerializer
             constructingBodyWithBlock:(nullable void (^)(id <AFMultipartFormData> _Nullable formData))block
                              progress:(nullable void(^)(NSProgress * _Nonnull uploadProgress))progress
                               success:(nullable void (^)(id _Nullable responseObject))success
                               failure:(nullable void (^)(NSError *_Nullable error))failure;


/**
 取消所有请求
 */
+ (void)cancelAllRequests;


@end
